package cn.zxh.improvement.common.core.utils;

import cn.zxh.improvement.common.core.enums.BaseEnum;
import cn.zxh.improvement.common.core.enums.BaseMessageEnum;
import cn.zxh.improvement.common.core.exceptions.IllegalArgumentCodeException;

import java.util.Objects;

/**
 * 断言工具类
 *
 * @author zxh
 * @since 2023/4/13 16:09:14
 */
public class Assert {

    /**
     * 不能为null, 为null抛异常
     *
     * @param o 被校验对象
     * @throws NullPointerException 空指针异常
     */
    public static void requireNonNull(Object o) {
        Objects.requireNonNull(o);
    }

    /**
     * 在条件不满足的情况下抛出IllegalArgumentException
     *
     * @param condition 校验的条件
     */
    public static void require(boolean condition) {
        if (!condition) {
            throw new IllegalArgumentCodeException();
        }
    }
}

